<!DOCTYPE html>
<html class="loginHtml">
<head>
	<meta charset="utf-8">
	<title>登录--layui后台管理模板 2.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" href="<?php echo ADMIN?>images/favicon.ico">
	<link rel="stylesheet" href="<?php echo _PUBLIC ?>layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="<?php echo ADMIN ?>css/public.css" media="all" />
</head>
<body class="loginBody">
	<form class="layui-form" >
		<div class="login_face"><img src="<?php echo ADMIN ?>images/face.jpg" class="userAvatar"></div>
		<div class="layui-form-item input-item">
			<label for="userName">用户名</label>
			<input type="text" placeholder="请输入用户名" name="adminName" autocomplete="off" id="userName" class="layui-input" lay-verify="required">
		</div>
		<div class="layui-form-item input-item">
			<label for="password">密码</label>
			<input type="password" placeholder="请输入密码" name="password" autocomplete="off" id="password" class="layui-input" lay-verify="required">
		</div>
		
		<div class="layui-form-item">
			<button class="layui-btn layui-block" id="login" lay-filter="login" lay-submit>登录</button>
		</div>
		
	</form>
	<script type="text/javascript" src="<?php echo _PUBLIC ?>layui/layui.js"></script>
	<script type="text/javascript" src="<?php echo ADMIN ?>js/cache.js"></script>
</body>
<script type="text/javascript">
layui.use(['form','layer','jquery'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer
        $ = layui.jquery;

    //表单输入效果
    $(".loginBody .input-item").click(function(e){
        e.stopPropagation();
        $(this).addClass("layui-input-focus").find(".layui-input").focus();
    })
    $(".loginBody .layui-form-item .layui-input").focus(function(){
        $(this).parent().addClass("layui-input-focus");
    })
    $(".loginBody .layui-form-item .layui-input").blur(function(){
        $(this).parent().removeClass("layui-input-focus");
        if($(this).val() != ''){
            $(this).parent().addClass("layui-input-active");
        }else{
            $(this).parent().removeClass("layui-input-active");
        }
    })
    
    form.on('submit(login)', function(data){  
      $.ajax({
			type:'post',
			data:data.field,
			dataType:'json',
			url:"<?php echo site_url('admin/login/login')?>",
			success:function(res){
				if(res.code==200){
					layer.msg('登录成功');
					location.href="<?php echo site_url('admin')?>";
				}else{
					layer.msg(res.msg);
				}
			},
			fail:function(){
				
			}
		})
		return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });
    
})


</script>
</html>